{extend name="public:base"}
{block name="main"}
<div class="demoTable">
  <a  href="{:Url('cateinfo',array('cateid'=>input('pid')))}" class="layui-btn" data-type="reload" lay-filter="cateadd" lay-submit>添加分类</a>
</div>
<table class="layui-table" lay-data="{height:650,url:'{:Url('catelist')}',where:{pid:'{:input('pid')}'}, page:true, id:'newslist'}" lay-filter="table">
  <thead>
    <tr>
      <th lay-data="{field:'catepx', width:80, sort: true}">排序</th>
      <th lay-data="{field:'cateid', width:80, sort: true}">ID</th>
      <th lay-data="{field:'catethumb', width:130}">缩略图</th>
      <th lay-data="{field:'catename', width:130}">分类名称</th>
      <th lay-data="{field:'url', width:200}">跳转连接</th>
      <th lay-data="{field:'modelname', width:120}">模型</th>
      <th lay-data="{field:'other', width:80}">备注</th>
      <th lay-data="{field:'isnav', width:80}">导航</th>
      <th lay-data="{field:'status', width:80}">状态</th>
      <th lay-data="{field:'addtime', width:180}">添加时间</th>
      <th lay-data="{fixed: 'right', width:350,  toolbar: '#barDemo'}">操作</th>
    </tr>
  </thead>
</table>


<script type="text/html" id="barDemo">
  
  <a class="layui-btn layui-btn-sm layui-btn-normal" lay-event="child">子菜单</a>
  <a class="layui-btn layui-btn-sm" lay-event="edit">编辑</a>
   
  <a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a>
  {{#  if(d.catetype == '单页面'){ }}
      <a class="layui-btn layui-btn-sm" lay-event="editpage">页面编辑</a>
  {{#  } }} 
</script>

<script>
layui.use(['table','laydate','form'], function(){
  var table = layui.table;
  var laydate = layui.laydate;
  var form = layui.form;
   laydate.render({
      elem: '#start',
      max: 0
   });
    laydate.render({
      elem: '#end',
      max: 1
   });
   
  var $ = layui.$;


  table.on('tool(table)', function(obj){
    var data = obj.data;

   if(obj.event === 'del'){
      layer.confirm('真的删除本条数据吗？', function(index){

        $.post("{:Url('catedel')}",{'cateid': data.cateid},function(data){
           if(data=='1'){
              alert();
              obj.del();
              layer.close(index);
           }else{
             alert("删除失败请重试！");
           }
        })
        
      });
    } else if(obj.event === 'edit'){
        location.href="/admin.php/cate/cateinfo/cateid/"+data.cateid;
      //layer.alert('编辑行：<br>'+ JSON.stringify(data))
    } else if(obj.event === 'editpage'){
        location.href="/admin.php/cate/pageinfo/cateid/"+data.cateid;
      //layer.alert('编辑行：<br>'+ JSON.stringify(data))
    } else if(obj.event === 'child'){
      location.href="/admin.php/cate/catelist/pid/"+data.cateid;
    }/* else if(obj.event === 'content'){
 			
    	console.log(obj.data.catetype);

   		if(obj.data.catetype=='单页面'){

   			location.href="/admin.php/cate/content/cateid/"+data.cateid;

   		}else if(obj.data.catetype=='文章模型'){

   			location.href="/admin.php/cate/newslist/cateid/"+data.cateid;

   		}
       
    }else if(obj.event === 'addcontent'){
    	location.href= "/admin.php/cate/content/cateid/"+data.cateid;
    }*/
    
  });

 //图片查看
  layer.photos({
    photos: 'div'
    ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
  });


});

</script>
{/block}